<?php
$num_show_page = 2;

$pag_i = $pag - $num_show_page;
if ($pag_i < 1) {
    $pag_i = 1;
}

$pag_f = $pag + $num_show_page;
if ($pag_f > $num_pag) {
    $pag_f = $num_pag;
}
?>

<div class="block center tCenter">
    <?php if ($pag_i > 1) { ?>
    <span class="pag" id="pag_1"><?= anchor("activity/show/", "First ..."); ?></span>
    <?php } ?>
    <?php for ($i = $pag_i; $i <= $pag_f; $i++) { ?>
        <span class="pag" id="pag_<?= $i?>"><?= anchor("activity/show/" . $i, $i); ?></span>
    <?php } ?>
    <?php if ($pag_f < $num_pag) { ?>
        <span class="pag" id="pag_<?= $num_pag?>"><?= anchor("activity/show/" . $num_pag, "... Last [".$num_pag."]"); ?></span>
    <?php } ?>
</div> 
<script type="text/javascript">
    $('.pag > a ').button();
    $('#pag_<?= $pag?> > a ').button( "disable" );
</script>
